package com.alan.controller;

import com.alan.entity.RestBean;
import com.alan.entity.dto.ScheduleUpdateDto;
import com.alan.service.ScheduleService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/schedule")
public class ScheduleController {

    @Resource
    private ScheduleService scheduleService;

    @PostMapping("/updateSchesule")
    //TODO:以后全部改成JSON数据
//    public RestBean updateSchedule(@RequestBody ScheduleUpdateDto dto){
    //'Content-Type': 'application/x-www-form-urlencoded'请求头无法使用 @RequestBody
    public RestBean updateSchedule(@RequestParam("userId") Integer userId,
                                   @RequestParam("listId") Integer listId,
                                   @RequestParam("learned")Integer learned,
                                   @RequestParam("ndtolearn")Integer ndtolearn){
        //封都封装了，用一下吧
        ScheduleUpdateDto scheduleUpdateDto = new ScheduleUpdateDto(userId,listId,learned,ndtolearn);

        return scheduleService.updateSchedule(scheduleUpdateDto) ;
    }

}
